package thread;

import sun.font.TrueTypeFont;

public class DaemonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread("rose"){
            public void run(){
                for (int i = 0; i < 5; i++) {
                    System.out.println(getName()+":let me go!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+":我没啦");
                System.out.println(getName()+":扑通");
            }
        };
        Thread jack = new Thread("jack"){
            public void run(){
                while (true){
                    System.out.println(getName()+":you jump,i jump");
                    try {
                        Thread.sleep(1200);
                    } catch (InterruptedException e) {
                        System.out.println(getName()+":我也没啦");
                    }
                }
            }
        };
        rose.start();
        jack.setDaemon(true);
        jack.start();
        System.out.println("main主线程结束");
    }
}
